package leetcode;

/**
 * Created by lyk on 2018-7-14.
 * Package name: leetcode
 * Porject name: untitled1
 */
public class TransposeMatrix {
    public int[][] transpose(int[][] A) {
        int R = A.length, C = A[0].length;
        int[][] ans = new int[C][R];
        for (int r = 0; r < R; ++r)
            for (int c = 0; c < C; ++c) {
                ans[c][r] = A[r][c];
            }
        return ans;
    }

    public static void main(String[] args) {
        TransposeMatrix tm = new TransposeMatrix();
        int[][] result = tm.transpose(new int[][]{
                {1,2,3},{4,5,6},{7,8,9}
        });
        for(int[] t : result){
            for (int i : t){
                System.out.print(i + "  ");
            }
            System.out.println();
        }
    }
}
